package CAT200;
import java.sql.*;
public class newDatabaseOrder
{
	public static void main(String[] args)
	{
		createTableAndInsertData();
	}
	
	public static void createTableAndInsertData()
	{
		try
		{
			DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
            Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/CAT200-DB", "user", "123");
            Statement stmt = con.createStatement();
            
            stmt.execute("create table ORDERS " +
            		"(" +
            		"ORDER_NUMBER varchar(10)," +
            		"ORDER_DATE date," +
            		"ORDER_PAID char(1)," +
            		"PAYMENT double," +
            		"CUST_USERNAME varchar(20)," +
            		"primary key(ORDER_NUMBER, CUST_USERNAME)," +
            		"foreign key(CUST_USERNAME) references CUSTOMER" +
            		")");
            System.out.println("table inserted");
            //stmt.execute("insert into FEEDBACK values (1, 'can't sign in?', '2010-9-20', 'loki', 'welcome to the derby')");
            //System.out.println("values inserted");
		}
		catch(Exception e){System.out.println(e); }
	}
}
